<?php
class AuthController extends mcz_Controller
{
	public function __construct()
	{
		$this->setLayout('layout');
	}

	public function indexAction()
	{
		if(!$_SESSION['obj']->isAuth())
		{
			$this->formAction();
		}
		else
		{
			$this->profileAction();
		}
	}

	public function formAction()
	{
		$this->display('form/login');
	}

	public function profileAction()
	{
		$this->assignToLayout('title',T('profile'));
		$this->display('profile');
	}

	public function loginAction()
	{
		if($_SESSION['obj']->login($_POST['login'], $_POST['password']))
		{
			header('location: ' . mczURL('/auth'));
			die;
		}
		else
		{
			$this->display('form/login', array('error' => true));
		}
	}
}